package cat.joronya.supermanager.drawer;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import cat.joronya.supermanager.R;

public class EmptyMessageFragment extends Fragment 
{
	public static final String MESSAGE_EXTRA = "cat.joronya.supermanager.message";
	
	public static EmptyMessageFragment newInstance(String message) 
    {
		EmptyMessageFragment f = new EmptyMessageFragment();

        // Supply index input as an argument.
        Bundle args = new Bundle();
        args.putString(MESSAGE_EXTRA, message);
        f.setArguments(args);

        return f;
    }
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) 
	{
		// If not container present, don't generate the view so this fragment
    	// is not visible. Doing so, may cause problems with FragmentManager on
    	// recreation of the activity when orientation changes occur and different
    	// layout is loaded with id's no present anymore on it.
    	if( container == null )
    	{
    		return null;
    	}
		
    	View view = inflater.inflate(R.layout.empty_fragment, null);
    	
    	String message = getArguments().getString(MESSAGE_EXTRA);
    	TextView messageView = (TextView)view.findViewById(R.id.message);
    	messageView.setText(message);
    	
    	return view;
	}
	
}
